import sys, getopt


def usage():
    print('-h: --help 帮助')
    print('-u: --url 域名')
    print('例如:test.py -u www.baidu.com')


def start(argv):
    url = ""
    file = ""
    if len(argv) < 1:
        print("-h 帮助信息;\n")
        sys.exit()
    try:
        opts, args = getopt.getopt(argv, "-u:-h", ["help", "file="])
    except getopt.GetoptError:
        print("请输入正确的参数")
        sys.exit()
    for opt, arg in opts:
        if opt == "-u":
            url = arg
        elif opt == "--file":
            file = arg
        elif (opt == "-h") or (opt == "--help"):
            usage()
        if (len(url) > 0) or (len(file) > 0):
            print(url, file)


if __name__ == '__main__':
    try:
        start(sys.argv[1:])
    except KeyboardInterrupt:
        print('aaa')
